﻿using static _06_AOP.BusinessLogic;

namespace _06_AOP
{
    internal class StaticProxyExample
    {
        /// <summary>
        /// 系统逻辑
        /// 切面1：校验能力
        /// </summary>
        public class PhoneServiceProxy1
            : IPhoneService//实现标准
        {
            private readonly IPhoneService _target;

            public PhoneServiceProxy1(IPhoneService target)
            {
                _target = target;
            }

            public string Mobile { get => _target.Mobile; set => _target.Mobile = value; }
            public string Message { get => _target.Message; set => _target.Message = value; }

            /// <summary>
            /// 子类重写父类方法
            /// </summary>
            public void Send()
            {
                Console.WriteLine("Proxy1:已对手机号进行验证");
                _target.Send();
                Console.WriteLine("Proxy1:已确认对方已经收到");
            }
        }
        /// <summary>
        /// 系统逻辑
        /// 切面2：
        /// </summary>
        public class PhoneServiceProxy2
           : IPhoneService//实现标准
        {
            private readonly IPhoneService _target;

            public PhoneServiceProxy2(IPhoneService target)
            {
                _target = target;
            }

            public string Mobile { get => _target.Mobile; set => _target.Mobile = value; }
            public string Message { get => _target.Message; set => _target.Message = value; }

            /// <summary>
            /// 子类重写父类方法
            /// </summary>
            public void Send()
            {
                Console.WriteLine("Proxy2:已开启加速通道");
                _target.Send();
                Console.WriteLine("Proxy2:已关闭加速通道");
            }
        }
    }
}
